﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using QLTV.DataTier;

namespace QLTV.ControllerTier
{
    class CSACH
    {
        MSACH mSach = new MSACH();

        public void LoadData(DataGrid dg)
        {
            dg.ItemsSource = mSach.Get_Sach();
        }

        public bool Kiemtra(SACH sach)
        {
            if (sach.MaTheLoai < 1 || sach.MaTheLoai > Global.getIns().getDb().LOAISACHes.Count())
            {
                MessageBox.Show("loi ma the loai");
                return false;
            }

            return true;
        }

        public void ThemSach(SACH s)
        {
            if (Kiemtra(s))
            {
                mSach.ThemSach(s);
            }
            else
            {

            }
        }

        public List<SACH> Tim(string theLoai)
        {
            return mSach.Get_Sach(theLoai);
        }
    }
}
